/****************************************************************************
 * Copyright (C) 2025 Chenyz. All rights reserved.
 *
 * @file    TinyOS_Objects.h
 *
 * @par     dependencies
 *          - stdint.h (Standard integer types)
 *          - TinyOS_Types.h (Type definitions)
 *          - TinyOS_Config.h (Configuration parameters)
 *
 * @author  Chenyz
 *
 * @brief   TinyOS Global Objects Declaration Header
 *          This file declares all global kernel objects and data structures
 *          used throughout the TinyOS real-time operating system, including:
 *          - Task management objects and control blocks
 *          - Scheduling and priority management structures
 *          - Timer and system timing objects
 *          - CPU usage monitoring variables
 *          - System-wide synchronization primitives
 *
 * @version V1.0
 * @date    2025-10-03
 *
 * @note    This header provides external access to kernel global objects
 *          and should be included by modules that need to interact with
 *          core system components.
 ****************************************************************************/

#ifndef __TINYOS_OBJECTS_H__
#define __TINYOS_OBJECTS_H__

/******************************** Includes **********************************/
#include <stdint.h>
#include "TinyOS_Types.h"
#include "TinyOS_Config.h"

/***************************** Global Object Declarations ****************************/

/* Task management objects */
extern TinyOS_TaskType*        CurrentTask;           /* Currently executing task */
extern TinyOS_TaskType*        NextTask;              /* Next task to be scheduled */
extern TinyOS_TaskType*        IdleTask;              /* Idle task reference */
extern TinyOS_TaskType         IdleTaskHandler;       /* Idle task control block */
extern TinyOS_TaskType         TimerTaskHandler;      /* Timer task control block */

/* Task stack allocations */
extern TinyOS_TaskStackType    IdleTaskStack[TINYOS_IDLE_TASK_STACK];   /* Idle task stack */
extern TinyOS_TaskStackType    TimerTaskStack[TINYOS_TIMER_TASK_STACK]; /* Timer task stack */

/* Scheduling and priority management */
extern TinyOS_ListType         TaskList[TINYOS_TASK_PRIORITY_COUNT];    /* Task lists by priority */
extern TinyOS_BitmapType       TaskPriorityBitmap;                      /* Ready task priority bitmap */
extern TinyOS_ListType         TaskDelayList;                           /* Delayed tasks list */
extern uint8_t                 SchedulerLockCount;                      /* Scheduler lock nesting counter */

/* Timer management objects */
extern TinyOS_ListType         TimerIntList;           /* Interrupt context timers */
extern TinyOS_ListType         TimerTaskList;          /* Task context timers */
extern TinyOS_TaskType*        TimerTask;              /* Timer task reference */
extern TinyOS_SemaphoreType    TimerProtectSem;        /* Timer list protection semaphore */
extern TinyOS_SemaphoreType    TimerTickSem;           /* Timer tick notification semaphore */

/* CPU usage monitoring variables */
extern uint32_t                IdleTaskRunningCount;   /* Current idle task execution count */
extern uint32_t                IdleTaskRunningCountMax; /* Maximum idle count for calibration */
extern uint32_t                SysTickCount;           /* System tick counter */
extern uint32_t                EnableCpuUsageState;    /* CPU usage monitoring state flag */

#endif /* __TINYOS_OBJECTS_H__ */

